<?php echo $this->renderPartial('_leftMenu'); ?>

<div class="caja_gris">
    <?php $this->widget('application.extensions.coolMessage.CoolMessage',array('jQuery'=>true));?>
	<script type="text/javascript">
	/**
	 *Esta función permite cambiar el estado de un usuario.	 
	 */
	function destacar(user){
		jQuery.ajax({
			'type':'POST',
			'data':'user='+user+'&YII_CSRF_TOKEN='+'<?php echo Yii::app()->request->getCsrfToken();?>',
			'url':'<?php echo $this->createUrl("status");?>',
			'cache':false,
			'success':function(html){
				jQuery('#destacar'+user).html(html);
			}
		});
		return false;
	}
	//--------------------------------------------------------
	/**
	 *Esta función permite realizar busquedas.	 
	 */
	function searchUsers()
	{	
		searchText = jQuery('#searchText').val();

		window.location = '<?php echo $this->createUrl("admin", array('size'=>$pages->pageSize));?>'+'/searchText/'+searchText;
	}
	//--------------------------------------------------------
	</script>
    <div class="breadcrumb"><strong>Usuarios</strong></div>
    <p class="titulo_seccion_gris">Usuarios</p>
    <div class="lista2">
    <?php echo CHtml::beginForm(array('admin'),'get',array('id'=>'frmSearch')); ?>
      <?php echo CHtml::hiddenField('r','admin'); ?>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td width="20" rowspan="6">&nbsp;</td>
          <td height="5" colspan="2">&nbsp;</td>
        </tr>
        <tr>
          <td width="80" height="30" class="margen1">Texto</td>
          <td><?php echo CHtml::textField('searchText','',array('class'=>'campo_texto')); ?></td>
        </tr>
        <tr>
          <td height="5"></td>
          <td><div class="botones_finales"><a class="botones_grises2" href="#" onClick="searchUsers();">Buscar</a></div></td>
        </tr>
      </table>
    <?php echo CHtml::endForm(); ?>
    </div>
    <div class="botonera">
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td width="120">
          <?php if(Yii::app()->user->getState("usr_profile") == User::ROLE_ADMIN): ?>
		  	     <?php echo CHtml::link('Agregar Usuario',array('create'),array('class'=>'botones_grises2')); ?>
		  	  <?php  endif; ?>
		  </td>
          <td>&nbsp;</td>
          <td width="69"></td>
        </tr>
      </table>
    </div>
    <div class="ver">
      Ver: 
      <?php echo CHtml::link('25',array('admin','size'=>'25','searchText'=>$searchText)); ?> / 
      <?php echo CHtml::link('50',array('admin','size'=>'50','searchText'=>$searchText)); ?> / 
      <?php echo CHtml::link('100',array('admin','size'=>'100','searchText'=>$searchText)); ?> / 
      <?php echo CHtml::link('Todos',array('admin','size'=>$pages->itemCount,'searchText'=>$searchText)); ?> 
    </div>
    <div class="lista">
    <?php echo CHtml::beginForm('','post',array('id'=>'frmItemList')); ?>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td height="25" width="75" align="center" class="titulo_lista">
          	<?php echo $sort->link('usr_nickname'); ?>
          	<?php $this->widget('application.extensions.ArrowOrder', array('rowName'=>'usr_nickname')); ?>
          </td>
          <td align="center" class="titulo_lista">
          	<?php echo $sort->link("usr_name"); ?>
          	<?php $this->widget('application.extensions.ArrowOrder', array('rowName'=>'usr_name')); ?>
          </td>
          <td align="center" class="titulo_lista">
          	<?php echo $sort->link("usr_email"); ?>
          	<?php $this->widget('application.extensions.ArrowOrder', array('rowName'=>'usr_email')); ?>
		  </td>
          <td width="70" align="center" class="titulo_lista">
          	<?php echo $sort->link("usr_profile"); ?>
          	<?php $this->widget('application.extensions.ArrowOrder', array('rowName'=>'usr_profile')); ?>
          </td>
          <td width="70" align="center" class="titulo_lista2">Activo</td>
          <td width="70" align="center" class="titulo_lista2">Editar</td>
        </tr>
		<?php foreach($models as $n=>$model): ?>
		<tr class="<?php echo $n%2?'':'fondo_blanco';?>">
          <td class="celda_lista"><?php echo CHtml::encode($model->usr_nickname); ?></td>
          <td class="celda_lista"><?php echo CHtml::encode($model->usr_name); ?></td>
          <td class="celda_lista"><?php echo CHtml::encode($model->usr_email); ?></td>
          <td class="celda_lista"><?php echo CHtml::encode($model->usr_profile); ?></td>
          <td class="celda_lista_img">
          	<a href="#" id="destacar<?php echo $model->usr_code;?>" onClick="destacar(<?php echo $model->usr_code;?>);"><img src="/images/<?php if($model->usr_status):?>destacar.gif<?php else:?>destacar2.gif<?php endif;?>" alt="Destacar"/></a>
          </td>
          <td class="celda_lista_img"><?php echo CHtml::link('<img src="/images/editar.gif" alt="Editar"/>',array('update','id'=>$model->usr_code)); ?></td>
        </tr>
        <?php endforeach; ?>
      </table>
    <?php echo CHtml::endForm(); ?>
    </div>
    <div class="caja_paginador2"><?php $this->widget('CLinkPager',array('pages'=>$pages,'header'=>'')); ?></div>
</div>